import print, {printHTML, printNode} from "../src/index";

/**
 * 
 * @param {string} id 
 * @param {()=> void} func 
 */
const addTestClick = (id, func) => {
    const basePrint = document.querySelector(id)
    basePrint.addEventListener("click", func)
}
addTestClick("#basePrint", () => {
    print(233)
})

const doc = `
  <h1>只因你太美</h1>
  <p>再看一眼多看一眼就会爆炸</p>
  <p>再近一点靠近一点就会融化</p>
  `

addTestClick("#maginprint", () => {
    printHTML(doc,{header: true, footer: true})
})

addTestClick("#nohead", () => {
    printHTML(doc,{header: false})
})
addTestClick("#nofoot", () => {
    printHTML(doc,{footer: false})
})

addTestClick("#nomaginprint", () => {
    printHTML(doc,{header: false, footer: false})
})

addTestClick("#landscape", () => {
    printHTML(doc,{header: false, footer: false, landscape: true})
})

addTestClick("#size", () => {
    const doc2=`
    <div>
        <style>
            .between {
                display: flex;
                justify-content: space-between;
            }
            * {
                font-size: 10px;
            }
        </style>
        <h3 style="text-align: center;">神奇百货龙华店</h3>
        <div class="between" style="border-bottom: 1px solid;">
            <div>收银员： 王招君</div>
            <div>打印时间： 2025-3-23</div>
        </div>
        <div class="between">
            <div>篮球</div>
            <div>x1</div>
            <div>¥50.00</div>
        </div>
        <div class="between">
            <div>烧鸡</div>
            <div>x1</div>
            <div>¥30.00</div>
        </div>
        <div class="between" style="border-top: 1px solid;">
            <div>总计： </div>
            <div>¥80.00</div>
        </div>
    </div>
    `
    printHTML(doc2,{header: false, footer: false, size: '80mm 100mm'})
})

addTestClick("#style", () => {
    const table = document.querySelector("table")
    printNode(table,{header: true, footer: true})
})



